package com.yunji.web.base;
/**
 * @Package com.yunji.web
 * FileName:	UserLoginController.java
 * Copyright:	Copyright © 2024 云集互联 All Rights Reserved
 * Company:		云集互联
 * @version: 1.0
 * @since: JDK 1.8.0_202
 * Create at:   2024-04-06 23:13:50
 * Description:
 * 用户登录
 * Modification History:
 * Author					Date					Version					Description
 * -------------------------------------------------------------------------------------
 * HuaAo0803@163.com	2024-04-06 23:13:50		1.0						1.0 Version
 */

import com.alibaba.fastjson2.JSONObject;
import com.yunji.base.business.UserLoginBusiness;
import com.yunji.base.domain.LoginStaffDO;
import com.yunji.base.domain.LoginWechatDO;
import com.yunji.common.base.BaseController;
import com.yunji.common.base.response.Response;
import com.yunji.common.base.response.ResponseHelper;
import com.yunji.common.model.domain.MemberDO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @version 1.0
 * @Project: yunji-coffee
 * @Package com.yunji.web.user
 * @FileName UserLoginController.java
 * @Copyright Copyright © 2024 云集互联. All Rights Reserved
 * Company		com
 * @CreateTime 2024-04-08 13:50:12
 * @Description 用户登录交互
 * @Modification Author                    History Time			Version				Description
 * --------------------------------------------------------------------------------
 * HuaAo				2024-04-08 13:50:12		1.0					1.0 Version
 * @since JDK 1.8.0_202
 */
@Api(tags = "管理端-登录模块")
@RestController
@RequestMapping("/gateway/home")
public class UserLoginController extends BaseController {
    @Autowired
    private UserLoginBusiness business;

    @ApiOperation("用户端微信登录")
    @PostMapping("loginByWeixin")
    public Response<Map<String, Object>> loginWechat(@RequestBody LoginWechatDO wechat) {
        return ResponseHelper.success(business.loginWechat(wechat));
    }

//    @ApiOperation("用户端微信登录")
//    @PostMapping("wechatLogin")
//    public Response<Map<String, Object>> wechatLogin(String openid, String phone) {
//        return ResponseHelper.success(business.wechatLogin(openid, phone));
//    }

    @ApiOperation("员工端登录")
    @PostMapping("loginByStaff")
    public Response<Map<String, Object>> loginStaff(@RequestBody LoginStaffDO staff) {
        return ResponseHelper.success(business.loginStaff(staff));
    }

    @ApiOperation("员工端微信登陆")
    @PostMapping("loginStaffByWeixin")
    public Response<Map<String, Object>> loginStaffWechat(@RequestBody LoginWechatDO wechat) {
        return ResponseHelper.success(business.loginStaffByWechat(wechat));
    }

    @ApiOperation("用户端获取用户信息")
    @GetMapping("getUser")
    public Response<MemberDO> getWechatUser() {
        return ResponseHelper.success(business.getWechatUser());
    }

    @ApiOperation("用户端微信登录")
    @GetMapping("getWXToken")
    public Response<JSONObject> getWechatToken(String phone) {
        return ResponseHelper.success(business.getWechatToken(phone));
    }
}
